package com.qeeyou.apps.android.craftsman.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Created by xuchengxiong on 2017/12/15.
 */

public abstract class BaseFragment extends Fragment {

    protected int layoutId;
    protected View view;
    protected Context context = getActivity();
    protected final Logger logger = Logger.getLogger(BaseFragment.class.getSimpleName());

    {
        logger.setLevel(Level.ALL);
    }

    protected BaseFragment(int layoutId) {
        this.layoutId = layoutId;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(layoutId, container, false);
        context = container.getContext();
        doOnCreate(savedInstanceState);
        return view;
    }

    protected abstract void doOnCreate(Bundle savedInstanceState);

    public View findViewById(int viewId) {
        return view.findViewById(viewId);
    }

}
